<template>
	<view class="u-bg-white">
		<!-- 顶部导航 -->
		<fa-navbar title="商会简介"></fa-navbar>
		<view class="content">
			<view class="title">
				<text style="color: #d9001b;font-weight: bold;">商会简介：</text>{{detailList.info}}
			</view>
			<!-- <view class="richText">
				{{detailList.content}}
			</view> -->
			<!-- <view class="richText">
				<text style="color: #d9001b; font-size: 32rpx; font-weight: bold;">内容：</text>
				<rich-text :nodes="detailList.content | formatRichText"></rich-text>
			</view> -->
			<text style="color: #d9001b; font-size: 32rpx; font-weight: bold;">内容：</text>
			<view class=" u-bg-white u-line-height" style="text-align: justify;text-align-last:left;">
				<u-parse :html="detailList.content" :tag-style="vuex_parse_style"
					:domain="vuex_config.upload ? vuex_config.upload.cdnurl : ''" @linkpress="navigate"></u-parse>
			</view>
			<!-- <view class="u-bg-white u-line-height">
				<u-parse :html="detailList.content" :tag-style="vuex_parse_style"
					:domain="vuex_config.upload ? vuex_config.upload.cdnurl : ''" @linkpress="navigate"></u-parse>
			</view> -->


		</view>
	</view>
</template>

<script>
	export default {



		data() {
			return {
				detailList: [],
				detailId: ''
			};
		},
		onLoad(options) {
			console.log(options);
			this.detailId = options.id
			this.getOrganizationDetail()

		},
		filters: {
			formatRichText(html) { //控制小程序中图片大小
				let newContent = html.replace(/<img[^>]*>/gi, function(match, capture) {
					match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
					match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
					match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
					return match;
				});
				newContent = newContent.replace(/style="[^"]+"/gi, function(match, capture) {
					match = match.replace(/width:[^;]+;/gi, 'max-width:100%;').replace(/width:[^;]+;/gi,
						'max-width:100%;');
					return match;
				});
				newContent = newContent.replace(/<br[^>]*\/>/gi, '');
				newContent = newContent.replace(/\<img/gi,
					'<img style="max-width:100%;height:auto;display:inline-block;margin:10rpx auto;"');
				return newContent;
			}
		},



		methods: {
			async getOrganizationDetail() {
				let data = {
					id: this.detailId
				}
				let res = await this.$api.getAssociationDetails(data)
				console.log(res, 'res')
				if (!res.code) {
					this.$u.toast(res.msg)
					return
				}
				this.detailList = res.msg
			}
		},
	}
</script>

<style lang="scss">
	page {
		background-color: #f4f6f8;
	}

	.content {
		padding: 30rpx;
		font-weight: normal;

		.title {
			// font-weight: bold;
			text-align: justify;
			font-size: 32rpx;
		}

		.richText {
			margin-top: 20rpx;
			text-align: justify;

			// font-size: 22rpx;
			richtext {
				image {
					width: 100%;
					height: 100%;
				}
			}
		}
	}
</style>
